Aiming to show a complete workthrough of 10X Spatial Gene Expression data from raw reads to analysis and visualization using 10X genomics spaceranger and Seurat.
Tutorial adapted from 10X spaceranger tutorial and Seurat vignette
The data is publicly available Mouse Kidney Section
https://www.10xgenomics.com/resources/datasets/mouse-kidney-section-coronal-1-standard-1-1-0
curl https://s3-us-west-2.amazonaws.com/10x.files/samples/spatial-exp/1.1.0/datasets/V1_Mouse_Kidney_fastqs.tar
-o V1_Mouse_Kidney/V1_V1_Mouse_Kidney_fastqs.tar
curl https://cf.10xgenomics.com/samples/spatial-exp/1.1.0/datasets/V1_Mouse_Kidney_image.tif -o V1_Mouse_Kidney/V1_Adult_V1_Mouse_Kidney_image.tif
tar -xvf datasets/V1_Mouse_Kidney_fastqs.tar
# Download mouse reference
curl -O https://cf.10xgenomics.com/supp/spatial-exp/refdata-gex-mm10-2020-A.tar.gz
Space ranger was used with the following params:
./spaceranger-2.0.0/spaceranger count --id="V1_Adult_Mouse_kidney" \
--description="Adult Mouse kidney (Coronal)" \
--transcriptome=refdata-gex-mm10-2020-A \
--fastqs=datasets/V1_Adult_Mouse_kidney_fastqs \
--image=datasets/V1_Adult_V1_Mouse_Kidney_image.tif \
--slide=V19L01-041 \
--area=C1 \
--jobmode=local \
--localcores=8 \
--localmem=40
library(Seurat)
library(ggplot2)
library(patchwork)
library(dplyr)
We are loading in the data directly from the output of spaceranger
Make sure hd5f libraries are installed
#kidney <-
kidney <- Load10X_Spatial(data.dir ="../Mouse-Kidney-section/outs/")
kidney
An object of class Seurat
32285 features across 1443 samples within 1 assay
Active assay: Spatial (32285 features, 0 variable features)
1 image present: slice1
plot1 <- VlnPlot(kidney, features = "nCount_Spatial", pt.size = 0.1) + NoLegend()
plot2 <- SpatialFeaturePlot(kidney, features = "nCount_Spatial") + theme(legend.position = "right")
wrap_plots(plot1, plot2)
The plots show quite a wide variance in molecular counts. This is due to technical variation but also due to natural variation in tissue types across the section. For this reason LogNormalise() is not suitable and Seurat reccomend rthe use of SCTransform() instead
kidney <- SCTransform(kidney, assay = "Spatial", verbose = FALSE)
Highlight particular features
SpatialFeaturePlot(kidney, features = c("Hpca", "Ttr"))
kidney <- RunPCA(kidney, assay = "SCT", verbose = FALSE)
kidney <- FindNeighbors(kidney, reduction = "pca", dims = 1:30)
kidney <- FindClusters(kidney, verbose = FALSE)
kidney <- RunUMAP(kidney, reduction = "pca", dims = 1:30)
Using method 'umap'
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
p1 <- DimPlot(kidney, reduction = "umap", label = TRUE)
p2 <- SpatialDimPlot(kidney, label = TRUE, label.size = 3)
p1 + p2
SpatialDimPlot(kidney, cells.highlight = CellsByIdentities(object = kidney, idents = c(0:10)), facet.highlight = TRUE, ncol = 5)
SpatialDimPlot(kidney, interactive = TRUE)
SpatialFeaturePlot(kidney, features = "Ttr", interactive = TRUE)
1st method : Using prior knowledge
de_markers <- FindMarkers(kidney, ident.1 = 5, ident.2 = 6)
| | 0 % ~calculating
|+ | 1 % ~13s
|++ | 2 % ~14s
|++ | 3 % ~12s
|+++ | 4 % ~11s
|+++ | 5 % ~10s
|++++ | 6 % ~09s
|++++ | 7 % ~08s
|+++++ | 8 % ~09s
|+++++ | 9 % ~08s
|++++++ | 10% ~08s
|++++++ | 11% ~08s
|+++++++ | 12% ~07s
|+++++++ | 13% ~07s
|++++++++ | 14% ~08s
|++++++++ | 15% ~07s
|+++++++++ | 16% ~07s
|+++++++++ | 17% ~07s
|++++++++++ | 18% ~07s
|++++++++++ | 19% ~07s
|+++++++++++ | 20% ~07s
|+++++++++++ | 21% ~07s
|++++++++++++ | 22% ~06s
|++++++++++++ | 23% ~06s
|+++++++++++++ | 24% ~06s
|+++++++++++++ | 25% ~06s
|++++++++++++++ | 26% ~06s
|++++++++++++++ | 27% ~06s
|+++++++++++++++ | 28% ~06s
|+++++++++++++++ | 29% ~06s
|++++++++++++++++ | 30% ~06s
|++++++++++++++++ | 31% ~05s
|+++++++++++++++++ | 32% ~05s
|+++++++++++++++++ | 33% ~05s
|++++++++++++++++++ | 34% ~05s
|++++++++++++++++++ | 35% ~05s
|+++++++++++++++++++ | 36% ~05s
|+++++++++++++++++++ | 37% ~05s
|++++++++++++++++++++ | 38% ~05s
|++++++++++++++++++++ | 39% ~05s
|+++++++++++++++++++++ | 40% ~05s
|+++++++++++++++++++++ | 41% ~04s
|++++++++++++++++++++++ | 42% ~04s
|++++++++++++++++++++++ | 43% ~04s
|+++++++++++++++++++++++ | 44% ~04s
|+++++++++++++++++++++++ | 45% ~04s
|++++++++++++++++++++++++ | 46% ~04s
|++++++++++++++++++++++++ | 47% ~04s
|+++++++++++++++++++++++++ | 48% ~04s
|+++++++++++++++++++++++++ | 49% ~04s
|++++++++++++++++++++++++++ | 51% ~04s
|++++++++++++++++++++++++++ | 52% ~04s
|+++++++++++++++++++++++++++ | 53% ~04s
|+++++++++++++++++++++++++++ | 54% ~03s
|++++++++++++++++++++++++++++ | 55% ~03s
|++++++++++++++++++++++++++++ | 56% ~03s
|+++++++++++++++++++++++++++++ | 57% ~03s
|+++++++++++++++++++++++++++++ | 58% ~03s
|++++++++++++++++++++++++++++++ | 59% ~03s
|++++++++++++++++++++++++++++++ | 60% ~03s
|+++++++++++++++++++++++++++++++ | 61% ~03s
|+++++++++++++++++++++++++++++++ | 62% ~03s
|++++++++++++++++++++++++++++++++ | 63% ~03s
|++++++++++++++++++++++++++++++++ | 64% ~03s
|+++++++++++++++++++++++++++++++++ | 65% ~03s
|+++++++++++++++++++++++++++++++++ | 66% ~03s
|++++++++++++++++++++++++++++++++++ | 67% ~02s
|++++++++++++++++++++++++++++++++++ | 68% ~02s
|+++++++++++++++++++++++++++++++++++ | 69% ~02s
|+++++++++++++++++++++++++++++++++++ | 70% ~02s
|++++++++++++++++++++++++++++++++++++ | 71% ~02s
|++++++++++++++++++++++++++++++++++++ | 72% ~02s
|+++++++++++++++++++++++++++++++++++++ | 73% ~02s
|+++++++++++++++++++++++++++++++++++++ | 74% ~02s
|++++++++++++++++++++++++++++++++++++++ | 75% ~02s
|++++++++++++++++++++++++++++++++++++++ | 76% ~02s
|+++++++++++++++++++++++++++++++++++++++ | 77% ~02s
|+++++++++++++++++++++++++++++++++++++++ | 78% ~02s
|++++++++++++++++++++++++++++++++++++++++ | 79% ~02s
|++++++++++++++++++++++++++++++++++++++++ | 80% ~01s
|+++++++++++++++++++++++++++++++++++++++++ | 81% ~01s
|+++++++++++++++++++++++++++++++++++++++++ | 82% ~01s
|++++++++++++++++++++++++++++++++++++++++++ | 83% ~01s
|++++++++++++++++++++++++++++++++++++++++++ | 84% ~01s
|+++++++++++++++++++++++++++++++++++++++++++ | 85% ~01s
|+++++++++++++++++++++++++++++++++++++++++++ | 86% ~01s
|++++++++++++++++++++++++++++++++++++++++++++ | 87% ~01s
|++++++++++++++++++++++++++++++++++++++++++++ | 88% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++ | 89% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++ | 90% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++ | 91% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++ | 92% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 93% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 94% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 95% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=07s
SpatialFeaturePlot(object = kidney, features = rownames(de_markers)[1:3], alpha = c(0.1, 1), ncol = 3)
2nd method: Looking for patterns in the data
kidney <- FindSpatiallyVariableFeatures(kidney, assay = "SCT", features = VariableFeatures(kidney)[1:500],
selection.method = "markvariogram")
More tutorials on data integration, subsetting and multiple slice data available at https://satijalab.org/seurat/articles/spatial_vignette.html
sessionInfo()